/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package suministros.ejb30.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Luis_Angel
 */
@Entity
@Table(name = "cargo_empresa")
@NamedQueries({
    @NamedQuery(name = "CargoEmpresa.findAll", query = "SELECT c FROM CargoEmpresa c"),
    @NamedQuery(name = "CargoEmpresa.findByCodCargo", query = "SELECT c FROM CargoEmpresa c WHERE c.codCargo = :codCargo"),
    @NamedQuery(name = "CargoEmpresa.findByNomCargo", query = "SELECT c FROM CargoEmpresa c WHERE c.nomCargo = :nomCargo")})
public class CargoEmpresa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "cod_cargo")
    private Integer codCargo;
    @Column(name = "nom_cargo")
    private String nomCargo;
    @OneToMany(mappedBy = "codCargo")
    private List<Trabajador> trabajadorList;

    public CargoEmpresa() {
    }

    public CargoEmpresa(Integer codCargo) {
        this.codCargo = codCargo;
    }

    public Integer getCodCargo() {
        return codCargo;
    }

    public void setCodCargo(Integer codCargo) {
        this.codCargo = codCargo;
    }

    public String getNomCargo() {
        return nomCargo;
    }

    public void setNomCargo(String nomCargo) {
        this.nomCargo = nomCargo;
    }

    public List<Trabajador> getTrabajadorList() {
        return trabajadorList;
    }

    public void setTrabajadorList(List<Trabajador> trabajadorList) {
        this.trabajadorList = trabajadorList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codCargo != null ? codCargo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CargoEmpresa)) {
            return false;
        }
        CargoEmpresa other = (CargoEmpresa) object;
        if ((this.codCargo == null && other.codCargo != null) || (this.codCargo != null && !this.codCargo.equals(other.codCargo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nomCargo;
    }

}
